<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<%@ include file="/commons/validation.jsp"%>
<%@ include file="/commons/dateTime.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script language="JavaScript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/pages/com/ce/pms/occupation/occupation.js"></script>
<script type="text/javascript">
//添加或编辑
function editItem(){
	var isPass=$('editForm').fireEvent("onSubmit");
	if(isPass){
		closeORopenButton();
		$('joinMode').disabled="";
		var url = '';

		$('perfectItemTypeConfigName').value = $('perfectItemTypeConfigId').options[$('perfectItemTypeConfigId').selectedIndex].text;
		//alert(perfectItemTypeConfigName);
		if(document.getElementById("keyword").value==''){
		url = '${ctx }/occupation_perfectItemRequisitionAction.do?method=addPerfectItemRequisition';
		}else{
		url = '${ctx }/occupation_perfectItemRequisitionAction.do?method=editPerfectItemRequisition';
		}
		var param = Form.serialize('editForm');
		new Ajax.Request(url,{method: 'post' , parameters: param, onSuccess : function(response){
			closeORopenButton();
			$('joinMode').disabled="disabled";
			ajaxSubmitException(response.responseText);
			if(response.responseText == 'true'){
				findFrame('perfectItemRequisitionList').parent.searchPerfectItemRequisition(null);
				windowClose();
			}
		}});
	}
}

//清除隐藏数据
function cleanValue(){
	$('ownerName').value = '';
}

function openSelectHouse(){
	cleanValue();
	var ownerUrl = PROJECT_NAME_PATH_MYCE + "/customer_chooseSingleHouseAction.do?method=chooseBuildingMain";
	ownerUrl += "&parentFrameId=EditPageIFarm";
	top.windowOpen(ownerUrl , "chooseBuildFrm", "选择房间",500,800);
}

function setHouseInfo(houseId,houseNum){	//设置房号


	//获取验房ID
	var IdentityValidateUrl = '${ctx}/occupation_perfectItemRequisitionAction.do?method=getIdentityValidate';
	new Ajax.Request(IdentityValidateUrl,{method: 'post', parameters: {houseId:houseId}, onComplete: function(responseValidate){
		ajaxSubmitException(responseValidate.responseText);
		$('houseNumber').value = houseNum;
		$('houseId').value = houseId;
		$('houseNumber').fireEvent("onblur");
		<c:if test="${perfectItemRequisitionVO.keyword == null }">
		$('inspectionRequisitionId').value = responseValidate.responseText;
		</c:if>
		//填写验房信息
		var url = "${ctx}/occupation_joinHandleAction.do?method=queryCustomerHouse";
		new Ajax.Request(url,{method: 'post', parameters: {houseId:houseId}, onComplete: function(response){

			if(response.responseText != 'false'){


				var rowss = $('otherHouseInfo').rows;
			    var len = rowss.length;
			    for(var i = 0 ; i <len;i++){
					$('otherHouseInfo').deleteRow();
				}
				
			var obj= eval("("+response.responseText+")");
			var str = "";
			var ownerSelf = '';
			for(var i = 0; i < obj.length;i++){
				str = str+obj[i].realHouseClientInfo;
				if(obj[i].houseNumber == houseNum ){
					//loadClient(obj[i].ownerName);
					//$('coalitionHouseNumber').innerText=obj[i].coalitionHouseNumber;
					//alert($('ownerSelf').innerHTML);
					//业主
					
					
					//ownerSelf = obj[i].ownerName+"&nbsp;"+obj[i].certificateNumberStr+"("+obj[i].certificateTypeStr+")<br />";
					<c:if test="${perfectItemRequisitionVO.keyword == null }">
					if($('ownerName').value == ''){
						$('ownerName').value = obj[i].ownerName;
					}
					else{
						$('ownerName').value = $('ownerName').value + ',' + obj[i].ownerName;
					}
					</c:if>
				}else{//管理房
					<c:if test="${perfectItemRequisitionVO.keyword == null }">
					if($('ownerName').value == ''){
						$('ownerName').value = obj[i].ownerName;
					}
					else{
						$('ownerName').value = $('ownerName').value + ',' + obj[i].ownerName;
					}
					</c:if>
					fillOtherHouseInfo(obj[i].houseNumber,obj[i].ownerName,obj[i].certificateNumberStr,obj[i].certificateTypeStr);
				}
			}
			var re = /#@/g;
			str = str.replace(re,"&nbsp;"); 
			$('ownerSelf').innerHTML = str;
				var manger = '${ctx }/occupation_perfectItemRequisitionAction.do?method=isManager';
			new Ajax.Request(manger,{method: 'post', parameters: {houseId:houseId}, onComplete: function(resmanage){

				var managestat = resmanage.responseText;
				if(managestat == '002'){
					$('joinMode').checked="checked";
				}
			}});

			}
			else{
					Alert("没有业主请重新选择!");
					return;
			}
		}});
	}});


}

function closeORopenButton(){
	$('btn1_22').disabled= !$('btn1_22').disabled;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>整改项目-编辑</title>
</head>

<body <c:if test="${perfectItemRequisitionVO.keyword != null }">onload="setHouseInfo('${perfectItemRequisitionVO.houseId }','${perfectItemRequisitionVO.houseNumber }' );"</c:if>>
<div style="overflow: auto; height: 460px; ">
<form name="editForm" id="editForm" class="required-validate" action="">
<input type="hidden" name="perfectItemTypeConfigName" id="perfectItemTypeConfigName" value="" />
<input type="hidden" name="keyword" id="keyword" value="${perfectItemRequisitionVO.keyword }" />
<input type="hidden" name="houseId" id="houseId" value="${perfectItemRequisitionVO.houseId }" />
<input type="hidden" name="inspectionRequisitionId" id="inspectionRequisitionId" value="${perfectItemRequisitionVO.inspectionRequisitionId }" />
<input type="hidden" name="ownerName" id="ownerName" value="${perfectItemRequisitionVO.ownerName }" />
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2" class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle" /> <span class="window_head_intext">登记申报项目</span></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2" class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td colspan="2" class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td colspan="2" class="content">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">

      <tr>
        <td class="aux_outtable_color"><table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
            <tr>
                                    <td valign="top" class="aux_intable_td1">房 号：</td>
                                    <td valign="middle" class="aux_intable_require"><table border="0" cellspacing="0" cellpadding="0">
                                        <tr>

                                          <td></td>
                                          <td></td>
                                        </tr>
                                        <tr>
                                          <td>
                                          <input readonly="readonly" name="houseNumber" id="houseNumber" type="text" value="${perfectItemRequisitionVO.houseNumber }" class="inputtext required" size="16" /></td>
                                          <td width="4">&nbsp;</td>
                                          <td><a href="#"  onClick="javascript:openSelectHouse();" onFocus="this.blur()"><img src="${ctx}/images/ico_houesno.GIF" <c:if test="${perfectItemRequisitionVO.keyword != null }">style="display: none;"</c:if> alt="请点选查找房号" border="0" /></a></td>
                                        </tr>
                                    </table></td>
              </tr>

			<tr>
			  <td valign="top" class="aux_intable_td1">业 主： </td>
			  <td valign="middle" class="aux_intable_td2"  id="ownerSelf">${perfectItemRequisitionVO.ownerName }
			  </td>
			  </tr>


			<tr>
			  <td colspan="2" valign="top" class="aux_titletable">管理房号:<span id="coalitionHouseNumber"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			    <input type="checkbox" name="joinMode" id="joinMode"  value="002" disabled="disabled" ><span style="font-weight:normal">按管理房办理</span></td>
			  </tr>
			<tbody id="otherHouseInfo">
			</tbody>


		   <tr>
            <td class="aux_intable_td1">申报日期：</td>
            <td class="aux_intable_require"><table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><input name="perfectRequisitionDate" id="perfectRequisitionDate" type="text" class="inputtext required validate-date-yyyy-mm-dd" value="${perfectItemRequisitionVO.perfectRequisitionDate }" size="16" /></td>
                <td width="4">&nbsp;</td>
                <td><img id="perfectRequisitionDateImg" src="${ctx}/images/ico_clock.gif" width="20" height="20" /></td>
              </tr>
            </table></td>
            </tr>
			<tr>
            <td class="aux_intable_td1">申报类型：</td>
            <td class="aux_intable_require">
			<pms:unitedSelect
              		name="perfectItemTypeConfigId"
              		id="perfectItemTypeConfigId"
              		optionLabel="perfectItemTypeName"
              		optionValue="keyword"
              		selectText="请选择..."
              		value="${perfectItemRequisitionVO.perfectItemTypeConfigId }"
              		dataList="${perfectItemTypeList }">
           	</pms:unitedSelect>
			</td>
            </tr>
			<tr>
            <td valign="top" class="aux_intable_td1">问题描述：</td>
            <td class="aux_intable_require_more">
              <textarea name="description" id="description" cols="26" rows="3" class="textareatext required max-length-200">${perfectItemRequisitionVO.description }</textarea>           </td>
            </tr>
			<tr>
            <td valign="top" class="aux_intable_td1">期望结果：</td>
            <td class="aux_intable_td2">
              <textarea name="expectationResult" id="expectationResult" cols="26" rows="3" class="textareatext max-length-100">${perfectItemRequisitionVO.expectationResult }</textarea>           </td>
            </tr>


        </table></td>
      </tr>
    </table>
	</td>
  </tr>
  <tr>

    <td class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_21"></td>
              <td class="buttonOffMiddle" id="btn1_22" onClick="javascript:editItem();" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onBlur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 保 存</td>
              <td class="buttonOffRight" id="btn1_23"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onClick="javascript:windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onBlur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 关 闭</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr style="height:30px;"><td>&nbsp;</td></tr>
</table>
</form>
</div>
<script type="text/javascript">
     Calendar.setup(
      {
       inputField : "perfectRequisitionDate", // ID of the input field
       ifFormat : "%Y-%m-%d", // the date format
       button : "perfectRequisitionDateImg", // ID of the button
      // align          :    "Tl",           // alignment (defaults to "Bl")
 		singleClick    :    true
      }
      );
     </script>
</body>
</html>